<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>反转链表</title>
</head>
<body>
  <a href="https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/">反转链表</a>
  <div>
    定义一个函数，输入一个链表的头节点，反转该链表并输出反转后链表的头节点。
  </div>
  <div>
    <span>解题思路：</span>
    链的翻转
  </div>
  <script>
    /**
     * @param {ListNode} head
     * @return {ListNode}
     */
    var reverseList = function(head) {
      let prev = null, curr = head;
      while (curr) {
        let next = curr.next;
        curr.next = prev;
        prev = curr;
        curr = next;
      }
      return prev;
    };
  </script>
</body>
</html>